<template>
  <div class="hello">
    <van-nav-bar title="商品详情" left-text="返回" left-arrow @click-left="onClickLeft" />
    <div>
      <img :src="list.avaUrl" />
      <p>{{ list.name }}</p>
      <p>{{ list.age }}</p>
      <p>{{ list.phone }}</p>
      <p>{{ list.detail }}</p>
    </div>
    <van-goods-action>
      <van-goods-action-icon icon="chat-o" text="客服" color="#ee0a24" />
      <van-goods-action-icon icon="cart-o" text="购物车" />
      <van-goods-action-icon icon="star" text="已收藏" color="#ff5000" />
      <van-goods-action-button type="warning" text="加入购物车" />
      <van-goods-action-button type="danger" text="立即购买" />
    </van-goods-action>
  </div>
</template>

<script>
import { Toast } from "vant";
import url from "../tools/url";
export default {
  name: "Detail",
  data() {
    return {
      list: "",
    };
  },
  methods: {
    onClickLeft() {
      this.$router.go(-1);
    },
  },
  mounted() {
    var id = this.$route.query.id;
    var token = sessionStorage.getItem("token");
    var str = `token=${token}&id=${id}`;
    this.axios.post(url.GET_SHOP_ID, str).then((res) => {
      console.log(res);
      if (res.data.code == 200) {
        this.list = res.data.data;
      } else {
        Toast(res.data.message);
      }
    });
  },
};
</script>

<style scoped>
.hello {
  text-align: center;
  margin-bottom: 80px;
}
</style>
